#region License

// This file is part of Grawlix.
// 
// Grawlix is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
// Grawlix is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public
// License along with Grawlix.  If not, see
// <http://www.gnu.org/licenses/>.

#endregion

using System;
using System.Diagnostics;
using Grawlix.Geometry;
using Grawlix.Services.Resources;

namespace Grawlix.Services.Rendering
{
	/// <summary>
	/// The public interface to game texture data.
	/// </summary>
	[Serializable]
	public sealed class Texture :
		AbstractResourceProxy<ITextureResource, Texture>,
		ITextureResource
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="Texture"/>
		/// class.
		/// </summary>
		/// <param name="identifier">The unique identifier for this
		/// instance.</param>
		internal Texture(Uri identifier)
			: base(identifier)
		{
		}

		/// <summary>
		/// Gets the dimensions of the texture.
		/// </summary>
		/// <value>The dimensions of the original image.</value>
		public Vector2 Dimensions
		{
			get { return State.Dimensions; }
		}

		/// <summary>
		/// Gets the state object for this resource.
		/// </summary>
		/// <value>The state object for this resource.</value>
		public ITextureState State
		{
			get
			{
				var state = UntypedState as ITextureState;
				Debug.Assert(state != null);
				return state;
			}
		}
	}
}